package cn.school.vo;

import java.io.Serializable;

/**
 * @author oldliu
 * @since 1.0
 */
//返回ajax结果的封装
public class AjaxResult implements Serializable {
    private int code=0;//0表示一切正常，其他数字表示错误，500，401是错误
    private String msg;
    private Object data;
    public AjaxResult(){

    }

    public AjaxResult(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public static AjaxResult success(Object obj){
        return new AjaxResult(0,"",obj);
    }
    public static AjaxResult success(String msg){
        return new AjaxResult(0,msg,null);
    }
    public static AjaxResult error(String msg){
        return new AjaxResult(500,msg,null);
    }
    public static AjaxResult error(int code,String msg){
        return new AjaxResult(code,msg,null);
    }
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
